package design.pattern.Lu03AbstractFactoryPattern;

/**
 * @program JavaBase
 * @description: 抽象工厂模式
 * @author: zhanglu
 * @create: 2020-03-27 14:46:00
 */
public class Lu03AbstractFactoryPattern {

    public static void main(String[] args) {

        HumanFactory2 femaleHumanFactory = new FemaleHumanFactory();
        Human2 blackHuman = femaleHumanFactory.createBlackHuman();
        blackHuman.getColor();
        blackHuman.talk();
        blackHuman.getSex();


    }

}

interface Human2{

    void getColor();

    void talk();

    void getSex();
}

abstract class AbstractWhiteHuman implements Human2{

    @Override
    public void getColor() {
        System.out.println("白色");
    }

    @Override
    public void talk() {
        System.out.println("英语");
    }

}

abstract class AbstractBlackHuman implements Human2{

    @Override
    public void getColor() {
        System.out.println("黑色");
    }

    @Override
    public void talk() {
        System.out.println("印度语");
    }

}

abstract class AbstractYellowHuman implements Human2{

    @Override
    public void getColor() {
        System.out.println("黄色");
    }

    @Override
    public void talk() {
        System.out.println("汉语");
    }

}

class WhiteFemaleHuman extends AbstractWhiteHuman{

    @Override
    public void getSex() {
        System.out.println("白色女性");
    }

}

class WhiteMaleHuman extends AbstractWhiteHuman{

    @Override
    public void getSex() {
        System.out.println("白色男性");
    }

}

class BlackFemaleHuman extends AbstractBlackHuman{

    @Override
    public void getSex() {
        System.out.println("黑色女性");
    }

}

class BlackMaleHuman extends AbstractBlackHuman{

    @Override
    public void getSex() {
        System.out.println("黑色男性");
    }

}

class YellowFemaleHuman extends AbstractYellowHuman{

    @Override
    public void getSex() {
        System.out.println("黄色女性");
    }

}

class YellowMaleHuman extends AbstractYellowHuman{

    @Override
    public void getSex() {
        System.out.println("黄色男性");
    }

}

interface HumanFactory2{

    Human2 createWhiteHuman();

    Human2 createBlackHuman();

    Human2 createYellowHuman();

}

class FemaleHumanFactory implements HumanFactory2{

    @Override
    public Human2 createWhiteHuman() {
        return new WhiteFemaleHuman();
    }

    @Override
    public Human2 createBlackHuman() {
        return new BlackFemaleHuman();
    }

    @Override
    public Human2 createYellowHuman() {
        return new YellowFemaleHuman();
    }
}

class MaleHumanFactory implements HumanFactory2{

    @Override
    public Human2 createWhiteHuman() {
        return new WhiteMaleHuman();
    }

    @Override
    public Human2 createBlackHuman() {
        return new BlackMaleHuman();
    }

    @Override
    public Human2 createYellowHuman() {
        return new YellowMaleHuman();
    }
}
